package java8;

import java8.entity.Employee;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class LambdaStreamMap2 {
    public static void main(String[] args) {

        Employee e1 = new Employee(1, 22, "F", "aa", "aa");
        Employee e2 = new Employee(2, 23, "M", "bb", "bb");
        Employee e3 = new Employee(3, 24, "F", "cc", "cc");
        Employee e4 = new Employee(4, 25, "M", "dd", "dd");
        Employee e5 = new Employee(5, 26, "M", "ee", "ee");
        Employee e6 = new Employee(6, 27, "F", "gg", "gg");

        List<Employee> employees = Arrays.asList(e1, e2, e3, e4, e5, e6);

        List<Employee> employeeList = employees.stream()
                .peek(e -> {//返回的参数是一样的话可以把 map 换成 peek 这样就省略了 return
                    e.setAge(e.getAge() + 1);
                    e.setGender(e.getGender().equals("M") ? "Male" : "Female");
                    //return e;//map 用于改造，改造万对象之后要返回
                }).collect(Collectors.toList());

        employeeList.forEach(System.out::println);
    }
}
